﻿@using NetCoreCMS.Common;
@using NetCoreCMS.Models;
@{
   Layout = "~/Areas/Admin/Views/Shared/_LayoutList.cshtml";
   ViewBag.Title = "后台导航管理";
   List<Navigation> list = ViewData["list"] as List<Navigation>;
}
@section HeaderContent{
   <style>
   .tree-list .col-1{ width:6%; text-align:center; }
   .tree-list .col-2{ width:14%; white-space:nowrap;word-break:break-all;overflow:hidden; }
   .tree-list .col-3{ width:46%; white-space:nowrap;word-break:break-all;overflow:hidden; }
   .tree-list .col-4{ width:6%; text-align:center; }
   .tree-list .col-5{ width:8%; text-align:center; }
   .tree-list .col-6{ width:8%; }
   .tree-list .col-7{ width:12%; text-align:center; }
   </style>

   <script>
      $(function () {
         //初始化分类的结构
         initCategoryHtml('.tree-list', 1);
         //初始化分类的事件
         $('.tree-list').initCategoryTree(true);
      });

      //保存数据
      function submitSave() {
         var $row = $("#ltable li");
         var json = { list: [] };
         $($row).each(function (i, item) {
            var id = $(item).find("label:eq(0)").text();
            var sortId = $(item).find(".sort").val();
            var obj = { id: id ,sortId: sortId};
            json.list.push(obj);
         });
         $.ajax({
            url: "SubmitSave",
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
               eval(data);
            },
            error: function () {
               alert("error");
            }
         });
      }

      //删除数据
      function __doPostBack() {
         var $row = $("#ltable li");
         var json = { list: [] };
         $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
               var id = $(item).find("label:eq(0)").text();
               var obj = { id: id };
               json.list.push(obj);
            }
         });
         $.ajax({
            url: "SubmitDelete",
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
               eval(data);
            },
            error: function () {
               alert("error");
            }
         });
      }
   </script>
}
<form id="form1"  method="post" action="#">
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
  <a href="../center/index"><i class="iconfont icon-home"></i><span>首页</span></a>
  <i class="arrow iconfont icon-arrow-right"></i>
  <span>后台导航管理</span>
</div>
<!--/导航栏-->

<!--工具栏-->
<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"><i class="iconfont icon-more"></i></a>
      <div class="l-list">
        <ul class="icon-list">
          <li><a href="../nav_edit/index?action=@CMSEnums.ActionEnum.Add"><i class="iconfont icon-close"></i><span>新增</span></a></li>
          <li><a href="javascript:;" id="btnSave" onclick="submitSave();"><i class="iconfont icon-save"></i><span>保存</span></a></li>
          <li><a href="javascript:;" onclick="checkAll(this);"><i class="iconfont icon-check"></i><span>全选</span></a></li>
          <li><a href="javascript:;" id="btnDelete" onclick="ExePostBack('btnDelete','本操作会删除本导航及下属子导航，是否继续？');"><i class="iconfont icon-delete"></i><span>删除</span></a></li>
        </ul>
      </div>
    </div>
  </div>
</div>
<!--/工具栏-->

<!--列表-->
<div class="table-container">
  <div class="tree-list">
    <div class="thead">
      <div class="col col-1">选择</div>
      <div class="col col-2">调用名称</div>
      <div class="col col-3">标题</div>
      <div class="col col-4">显示</div>
      <div class="col col-5">默认</div>
      <div class="col col-6">排序</div>
      <div class="col col-7">操作</div>
    </div>
    <ul id="ltable">
      @foreach(Navigation dr in list){
      <li class="layer-@dr.class_layer">
        <div class="tbody">
          <div class="col col-1">
              <span class="checkall" style="vertical-align:middle">
               @if (dr.is_sys == 0) {
                 <input type="checkbox" />
               }
               else {
                 <input type="checkbox" disabled="disabled" />
               }
              </span>
              <label style="display:none">@dr.id</label>
          </div>
          <div class="col col-2">
            @dr.name
          </div>
          <div class="col index col-3">
            <a href="../nav_edit/index?action=@CMSEnums.ActionEnum.Edit&id=@dr.id">@dr.title</a>
            @(dr.link_url == "" ? "" : "(链接：" + dr.link_url + ")")
          </div>
          <div class="col col-4">
            @(dr.is_lock == 0 ? "√" : "×")
          </div>
          <div class="col col-5">
            @(dr.is_sys == 1 ? "√" : "×")
          </div>
          <div class="col col-6">
            @Html.TextBox("txtSortId", dr.sort_id, new { @class="sort", onkeydown="return checkNumber(event);"})
          </div>
          <div class="col col-7">
            <a href="../nav_edit/index?action=@CMSEnums.ActionEnum.Add&id=@dr.id">添子级</a>
            <a href="../nav_edit/index?action=@CMSEnums.ActionEnum.Edit&id=@dr.id">修改</a>
          </div>
        </div>
      </li>
      }
    </ul>
  </div>
</div>
<!--/列表-->

</form>
